<?php
class Plugin{
	/**
	 * 
	 *
	 * @param Controller $controller
	 */
	static function test($controller){
//		var_dump($controller);
	}
	
	public static function vcode_seed($controller){
		$r = 0.2;
		if(Controller::$login){
			$uid = Controller::$login['uid'];
			$v = Cache::getInstance()->load('vcode_'.$uid);
			if(!$v){
				if(rand(0, 10000)/10000<$r){
					Cache::getInstance()->save(true, 'vcode_'.$uid);
					$controller->_needVcode = true;
				}
			}else{
				$controller->_needVcode = true;
			}
		}
		
//		var_dump($controller->_needVcode);
	}
	
	public static function vcode_clean(){
		if(Controller::$login){
			$uid = Controller::$login['uid'];
			Cache::getInstance()->remove('vcode_'.$uid);
		}
	}
	
	public static function vcode_get($uid){
		return Cache::getInstance()->load('vcode_'.$uid);
	}
}